package com.yuyou.fn.analyze.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.wens.mybatisplus.examples.Example;
import com.github.wens.mybatisplus.plugins.Page;
import com.yuyou.fn.analyze.entity.TeacherTarget;
import com.yuyou.fn.analyze.service.*;
import com.yuyou.fn.analyze.vo.*;
import com.yuyou.fn.common.constant.AccessTypeEnum;
import com.yuyou.fn.common.constant.JobNatureEnum;
import com.yuyou.fn.common.exception.BusException;
import com.yuyou.fn.common.service.ISiteConfigService;
import com.yuyou.fn.common.util.*;
import com.yuyou.fn.educational.entity.*;
import com.yuyou.fn.educational.service.*;
import com.yuyou.fn.educational.vo.*;
import com.yuyou.fn.educational.vo.PeriodRelativeVo;
import com.yuyou.fn.platform.entity.AreaTeam;
import com.yuyou.fn.platform.entity.BusTeam;
import com.yuyou.fn.platform.entity.SysUser;
import com.yuyou.fn.platform.service.IAreaTeamService;
import com.yuyou.fn.platform.service.IBusTeamService;
import com.yuyou.fn.report.entity.CostOfGradeSubject;
import com.yuyou.fn.report.service.*;
import com.yuyou.fn.report.vo.*;
import com.yuyou.fn.settlement.constant.IncomeCategoryEnum;
import com.yuyou.fn.settlement.constant.Subjects;
import com.yuyou.fn.settlement.entity.ChangeRecord;
import com.yuyou.fn.settlement.entity.IncomeCategory;
import com.yuyou.fn.settlement.entity.MainAccount;
import com.yuyou.fn.settlement.entity.TradeProp;
import com.yuyou.fn.settlement.service.IChangeRecordService;
import com.yuyou.fn.settlement.service.ITradePropService;
import com.yuyou.fn.settlement.vo.ChangeRecordQueryVo;
import com.yuyou.fn.settlement.vo.FeeCategoryTreeMapVo;
import com.yuyou.fn.settlement.vo.MainAccountAmountVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.awt.geom.Area;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;

import static com.yuyou.fn.settlement.constant.FeeCategoryEnum.SALARY_OF_COURSE;
import static com.yuyou.fn.settlement.constant.IncomeCategoryEnum.COURSE_INCOME;

/**
 *
 * ProductTarget 表数据服务层接口实现类
 *
 */
@Service
public class CostCenterServiceImpl implements ICostCenterService {

    @Resource
    private IMergeStudentRegDetailService mergeStudentRegDetailService;

    @Resource
    private ITeacherTargetService teacherTargetService;

    @Resource
    private IPeriodService periodService;

    @Resource
    private ITeacherService teacherService;

    @Resource
    private IAreaTeamService areaTeamService;

    @Resource
    private IBusTeamService busTeamService;

    @Resource
    private IMainAccountTargetService mainAccountTargetService;

    @Resource
    private IClassLectureDetailService classLectureDetailService;

    @Resource
    private IConsumeRecordService consumeRecordService;

    @Resource
    private IAttendClassLectureService attendClassLectureService;

    @Resource
    private ICourseTemplateService courseTemplateService;

    @Resource
    private ICourseClassService courseClassService;

    @Override
    public List<EmployeeMessageVo> findEmployeeMessage(TeacherQueryVo teacherQueryVo) {

        List<Teacher> teacherList=teacherService.findTeacherByQueryForList(teacherQueryVo);
        Map<Long,AreaTeam> areaTeamMap=this.findAreaTeamMapByTeacherList(teacherList);
        Map<Long,BusTeam> busTeamMap=this.findBusTeamMapByTeacherList(teacherList);

        List<EmployeeMessageVo> employeeMessageVoList=new ArrayList<>();

        for (Teacher teacher:teacherList){
            EmployeeMessageVo employeeMessageVo=new EmployeeMessageVo();
            AreaTeam areaTeam=areaTeamMap.get(teacher.getAreaTeamId());
            if (areaTeam==null){
                continue;
            }
            BusTeam busTeam=busTeamMap.get(teacher.getBusTeamId());
            this.fillEmployeeBassMessage(employeeMessageVo,teacher,areaTeam,busTeam);

            employeeMessageVoList.add(employeeMessageVo);
        }
        return employeeMessageVoList;
    }

    @Override
    public List<NewOldStudentBranchAdvanceVo> findNewOldStudentBranchAmount(StudentRegDetailQueryVo studentRegDetailQueryVo) {
        List<NewOldStudentBranchAdvanceVo> newOldStudentBranchAdvanceVoList=mergeStudentRegDetailService.findNewOldStudentBranchAmount(studentRegDetailQueryVo);
        List<Long> employeeIds = Utils.removeDuplicate(BeanUtils.toList(newOldStudentBranchAdvanceVoList, "employeeId"));
        List<Long> periodIds=Utils.removeDuplicate(BeanUtils.toList(newOldStudentBranchAdvanceVoList,"periodId"));
        List<Period> periodList=periodService.findByIds(periodIds);
        Map<Long, Period> periodMap = BeanUtils.toMap(periodList, "periodId");

        List<Teacher> teacherList=teacherService.findByIds(employeeIds);
        Map<Long,Teacher> teacherMap=BeanUtils.toMap(teacherList,"teacherId");


        Map<Long, AreaTeam> areaTeamMap=this.findAreaTeamMapByTeacherList(teacherList);
        Map<Long, BusTeam> busTeamMap=this.findBusTeamMapByTeacherList(teacherList);

        Iterator<NewOldStudentBranchAdvanceVo> iterator=newOldStudentBranchAdvanceVoList.iterator();
        while (iterator.hasNext()){
            NewOldStudentBranchAdvanceVo newOldStudentBranchAdvanceVo=iterator.next();
            Long employeeId=newOldStudentBranchAdvanceVo.getEmployeeId();
            Long periodId=newOldStudentBranchAdvanceVo.getPeriodId();
            Teacher teacher=teacherMap.get(employeeId);
            if (teacher==null){
                iterator.remove();
                continue;
            }
            Period period=periodMap.get(periodId);
            newOldStudentBranchAdvanceVo.setPeriodName(period.getPeriodName());

            BusTeam busTeam = busTeamMap.get(teacher.getBusTeamId());
            AreaTeam areaTeam=areaTeamMap.get(teacher.getAreaTeamId());
            this.fillEmployeeBassMessage(newOldStudentBranchAdvanceVo,teacher,areaTeam,busTeam);
        }


        return newOldStudentBranchAdvanceVoList;
    }

    @Override
    public List<SeqStepStudentBranchAdvanceVo> findSeqStepStudentBranchAmount(RegRelativceQueryVo regRelativceQueryVo, PeriodQueryRegVo periodQueryRegVo) {
        List<SeqStepStudentBranchAdvanceVo> seqStepStudentBranchAdvanceVoList=mergeStudentRegDetailService.findSeqStepStudentBranchAmount(regRelativceQueryVo,periodQueryRegVo);
        List<Long> employeeIds = Utils.removeDuplicate(BeanUtils.toList(seqStepStudentBranchAdvanceVoList, "employeeId"));
        List<Long> periodIds=Utils.removeDuplicate(BeanUtils.toList(seqStepStudentBranchAdvanceVoList,"periodId"));
        List<Period> periodList=periodService.findByIds(periodIds);
        Map<Long, Period> periodMap = BeanUtils.toMap(periodList, "periodId");

        List<Teacher> teacherList=teacherService.findByIds(employeeIds);
        Map<Long,Teacher> teacherMap=BeanUtils.toMap(teacherList,"teacherId");

        Map<Long, BusTeam> busTeamMap = this.findBusTeamMapByTeacherList(teacherList);
        Map<Long,AreaTeam> areaTeamMap=this.findAreaTeamMapByTeacherList(teacherList);

        Iterator<SeqStepStudentBranchAdvanceVo> iterator=seqStepStudentBranchAdvanceVoList.iterator();

        while (iterator.hasNext()){
            SeqStepStudentBranchAdvanceVo seqStepStudentBranchAdvanceVo=iterator.next();
            Long employeeId=seqStepStudentBranchAdvanceVo.getEmployeeId();
            Long periodId=seqStepStudentBranchAdvanceVo.getPeriodId();
            Teacher teacher=teacherMap.get(employeeId);
            if (teacher==null){
                iterator.remove();
                continue;
            }
            Period period=periodMap.get(periodId);
            seqStepStudentBranchAdvanceVo.setPeriodName(period.getPeriodName());
            BusTeam busTeam = busTeamMap.get(teacher.getBusTeamId());
            AreaTeam areaTeam=areaTeamMap.get(teacher.getAreaTeamId());
            this.fillEmployeeBassMessage(seqStepStudentBranchAdvanceVo,teacher,areaTeam,busTeam);
        }


        return seqStepStudentBranchAdvanceVoList;
    }

    @Override
    public List<PeriodStudentBranchVo> findPeriodStudentBranch(List<Long> periodIds) {
        List<Period> periodList=periodService.findByIds(periodIds);
        List<PeriodRelativeVo> periodRelativeVoList=periodService.findPeriodRelativeByPeriodIds(periodIds);
        List<Long> relativePeriodIds=new ArrayList<>();
        for (PeriodRelativeVo periodRelativeVo :periodRelativeVoList){
            relativePeriodIds.addAll(periodRelativeVo.getRelativePeriodIds());
        }
        final List<Long> realRelativePeriodIds=Utils.removeDuplicate(relativePeriodIds);
        Map<Long, Period> periodMap = BeanUtils.toMap(periodList, "periodId");
        Future<List<NewOldStudentBranchAdvanceVo>> futureNewOldStudentBranchAdvanceVo= Threads.dispatch(()->{
            StudentRegDetailQueryVo studentRegDetailQueryVo=new StudentRegDetailQueryVo();
            studentRegDetailQueryVo.setPeriodIds(periodIds);
            return this.findNewOldStudentBranchAmount(studentRegDetailQueryVo);
        });

        Future<List<SeqStepStudentBranchAdvanceVo>>  futureSeqStepStudentBranchAdvanceVo= Threads.dispatch(()->{
            RegRelativceQueryVo regRelativceQueryVo=new RegRelativceQueryVo();
            regRelativceQueryVo.setPeriodIds(realRelativePeriodIds);
            regRelativceQueryVo.setPeriodRelativeVoList(periodRelativeVoList);
            PeriodQueryRegVo periodQueryRegVo=new PeriodQueryRegVo();
            periodQueryRegVo.setPeriodIds(periodIds);

            return this.findSeqStepStudentBranchAmount(regRelativceQueryVo,periodQueryRegVo);
        });

        Future<List<TeacherTarget>> futureTeacherTargetByPeriodIdsAndTargetTypes=Threads.dispatch(()->{
            return teacherTargetService.findTeacherTargetByPeriodIdsAndTargetTypes(periodIds, Arrays.asList(10));
        });

        List<NewOldStudentBranchAdvanceVo> newOldStudentBranchAdvanceVoList=Threads.get(futureNewOldStudentBranchAdvanceVo);
        List<SeqStepStudentBranchAdvanceVo> seqStepStudentBranchAdvanceVoList=Threads.get(futureSeqStepStudentBranchAdvanceVo);
        List<TeacherTarget> teacherTargetByPeriodIdsAndTargetTypes = Threads.get(futureTeacherTargetByPeriodIdsAndTargetTypes);
        HashMap<String,PeriodStudentBranchVo> periodStudentBranchVoHashMap=new HashMap<>();
        for (NewOldStudentBranchAdvanceVo newOldStudentBranchAdvanceVo:newOldStudentBranchAdvanceVoList){
            String key=newOldStudentBranchAdvanceVo.getPeriodId()+"_"+newOldStudentBranchAdvanceVo.getEmployeeId();
            PeriodStudentBranchVo periodStudentBranchVo=periodStudentBranchVoHashMap.get(key);
            if (periodStudentBranchVo==null){
                periodStudentBranchVo=new PeriodStudentBranchVo();
                BeanUtils.copyProperties(periodStudentBranchVo,newOldStudentBranchAdvanceVo);
                periodStudentBranchVoHashMap.put(key,periodStudentBranchVo);
            }
            periodStudentBranchVo.setNewOldBranchNum(newOldStudentBranchAdvanceVo.getNewOldStudentNum());
        }

        for (SeqStepStudentBranchAdvanceVo seqStepStudentBranchAdvanceVo:seqStepStudentBranchAdvanceVoList){
            String key=seqStepStudentBranchAdvanceVo.getPeriodId()+"_"+seqStepStudentBranchAdvanceVo.getEmployeeId();
            PeriodStudentBranchVo periodStudentBranchVo=periodStudentBranchVoHashMap.get(key);
            if (periodStudentBranchVo==null){
                periodStudentBranchVo=new PeriodStudentBranchVo();
                BeanUtils.copyProperties(periodStudentBranchVo,seqStepStudentBranchAdvanceVo);
                periodStudentBranchVoHashMap.put(key,periodStudentBranchVo);
            }
            periodStudentBranchVo.setSeqStepBranchNum(seqStepStudentBranchAdvanceVo.getSeqStepNum());
        }

        List<Long> teacherIds = Utils.removeDuplicate(BeanUtils.toList(teacherTargetByPeriodIdsAndTargetTypes, "teacherId"));
        List<Teacher> teacherList=teacherService.findByIds(teacherIds);
        Map<Long, Teacher> teacherMap = BeanUtils.toMap(teacherList, "teacherId");
        Map<Long, AreaTeam> areaTeamMap =this.findAreaTeamMapByTeacherList(teacherList);
        Map<Long,BusTeam> busTeamMap=this.findBusTeamMapByTeacherList(teacherList);
        for (TeacherTarget teacherTarget:teacherTargetByPeriodIdsAndTargetTypes){
            String key=teacherTarget.getPeriodId()+"_"+teacherTarget.getTeacherId();
            PeriodStudentBranchVo periodStudentBranchVo=periodStudentBranchVoHashMap.get(key);
            if (periodStudentBranchVo==null){
                periodStudentBranchVo=new PeriodStudentBranchVo();
                Teacher teacher=teacherMap.get(teacherTarget.getTeacherId());
                if (teacher==null){
                    continue;
                }
                Period period=periodMap.get(teacherTarget.getPeriodId());
                AreaTeam areaTeam=areaTeamMap.get(teacher.getAreaTeamId());
                BusTeam busTeam=busTeamMap.get(teacher.getBusTeamId());
                this.fillEmployeeBassMessage(periodStudentBranchVo,teacher,areaTeam,busTeam);

                periodStudentBranchVo.setPeriodId(period.getPeriodId());
                periodStudentBranchVo.setPeriodName(period.getPeriodName());

                periodStudentBranchVoHashMap.put(key,periodStudentBranchVo);

            }
            String targetNum= teacherTarget.getTargetNum();
            if (StringUtils.isEmpty(targetNum) || StringUtils.isEmpty(targetNum.trim())){
                periodStudentBranchVo.setNewOldBranchTargetNum(0);
            }else {
                periodStudentBranchVo.setNewOldBranchTargetNum(Integer.parseInt(targetNum));
            }
        }
        Collection<PeriodStudentBranchVo> periodStudentBranchVoCollection=periodStudentBranchVoHashMap.values();
        List<PeriodStudentBranchVo> periodStudentBranchVoList=new ArrayList<>(periodStudentBranchVoCollection);

        return periodStudentBranchVoList;
    }

    @Override
    public List<NoCounselorBranchVo> countBusTeamOlineNoCounselorBranch(StudentRegDetailQueryVo studentRegDetailQueryVo) {
        List<NoCounselorBranchVo> noCounselorBranchVos = mergeStudentRegDetailService.countBusTeamOlineNoCounselorBranch(studentRegDetailQueryVo);
        return noCounselorBranchVos;
    }

    @Override
    public List<PeriodBonusCompletionRateVo> findPeriodBonusCompletionRate() {
        //mainAccountTargetService.findbyp
        return null;
    }

    @Override
    public List<CounselorBranchAdvanceVo> findCounselorBranchAdvanceByStudentState(StudentRegDetailQueryVo studentRegDetailQueryVo) {
        List<CounselorBranchAdvanceVo> counselorBranchAdvanceVoList=mergeStudentRegDetailService.findCounselorBranchAdvanceByStudentState(studentRegDetailQueryVo);
        List<Long> employeeIds = Utils.removeDuplicate(BeanUtils.toList(counselorBranchAdvanceVoList, "employeeId"));
        List<Teacher> teacherList=teacherService.findByIds(employeeIds);
        Map<Long, Teacher> teacherMap = BeanUtils.toMap(teacherList,"teacherId");
        Map<Long,AreaTeam> areaTeamMap=this.findAreaTeamMapByTeacherList(teacherList);
        Map<Long,BusTeam> busTeamMap=this.findBusTeamMapByTeacherList(teacherList);
        Iterator<CounselorBranchAdvanceVo> iterator = counselorBranchAdvanceVoList.iterator();
        while (iterator.hasNext()){
            CounselorBranchAdvanceVo counselorBranchAdvanceVo=iterator.next();
            Teacher teacher=teacherMap.get(counselorBranchAdvanceVo.getEmployeeId());
            if (teacher==null){
                iterator.remove();
                continue;
            }

            AreaTeam areaTeam=areaTeamMap.get(teacher.getAreaTeamId());
            BusTeam busTeam=busTeamMap.get(teacher.getBusTeamId());
            this.fillEmployeeBassMessage(counselorBranchAdvanceVo,teacher,areaTeam,busTeam);

        }
        return counselorBranchAdvanceVoList;
    }

    @Override
    public List<EmployeeCourseVo> findEmployeeCourse(ClassLectureDetailQueryVo classLectureDetailQueryVo) {
        List<EmployeeCourseVo> employeeCourseVoList = classLectureDetailService.findEmployeeCourse(classLectureDetailQueryVo);
        List<Long> employeeIds = Utils.removeDuplicate(BeanUtils.toList(employeeCourseVoList, "employeeId"));
        List<Teacher> teacherList=teacherService.findByIds(employeeIds);
        Map<Long, Teacher> teacherMap = BeanUtils.toMap(teacherList, "teacherId");
        for (EmployeeCourseVo employeeCourseVo:employeeCourseVoList){
            Teacher teacher=teacherMap.get(employeeCourseVo.getEmployeeId());
            if (teacher!=null){
                employeeCourseVo.setUniqueId(teacher.getIdNo());
                employeeCourseVo.setEmployeeName(teacher.getTeacherName());
            }
        }
        return employeeCourseVoList;
    }

    @Override
    public List<EmployeeAttendanceVo> findEmployeeAttendance(AttendClassLectureQueryVo attendClassLectureQueryVo) {
        List<AttendClassLecture> attendClassLectureList = attendClassLectureService.findAttendClassLectureListByQuery(attendClassLectureQueryVo);
        List<Long> classIds = Utils.removeDuplicate(BeanUtils.toList(attendClassLectureList, "classId"));
        List<CourseClass> courseClassList=courseClassService.findByIds(classIds,CourseClass.BASE_FIELDS);
        Map<Long, CourseClass> classMap = BeanUtils.toMap(courseClassList, "classId");
        List<Long> courseTemplateIds = BeanUtils.toList(courseClassList, "courseTemplateId");
        List<CourseTemplate> courseTemplateList=courseTemplateService.findByIds(courseTemplateIds,"courseTemplateId","courseName");
        Map<Long, CourseTemplate> courseTemplateMap = BeanUtils.toMap(courseTemplateList, "courseTemplateId");
        List<EmployeeAttendanceVo> employeeAttendanceVoList=new ArrayList<>(attendClassLectureList.size());
        List<Long> teacherIds = BeanUtils.toList(attendClassLectureList, "teacherId");
        List<Teacher> teacherList=teacherService.findByIds(teacherIds,"teacherId","teacherName","idNo");
        Map<Long, Teacher> teacherMap = BeanUtils.toMap(teacherList, "teacherId");

        for (AttendClassLecture attendClassLecture:attendClassLectureList){
            Teacher teacher=teacherMap.get(attendClassLecture.getTeacherId());
            if (teacher==null){
                continue;
            }
            CourseClass courseClass=classMap.get(attendClassLecture.getClassId());
            CourseTemplate courseTemplate=courseTemplateMap.get(courseClass.getCourseTemplateId());
            EmployeeAttendanceVo employeeAttendanceVo=new EmployeeAttendanceVo();
            employeeAttendanceVo.setAreaTeamId(courseClass.getClassId());
            employeeAttendanceVo.setAreaTeamName(courseClass.getAreaTeamName());
            employeeAttendanceVo.setClassId(courseClass.getClassId());
            employeeAttendanceVo.setClassNo(courseClass.getClassNo());
            employeeAttendanceVo.setClassName(courseClass.getClassName());
            employeeAttendanceVo.setCourseName(courseTemplate.getCourseName());
            employeeAttendanceVo.setCourseNo(courseTemplate.getCourseTemplateId().toString());
            employeeAttendanceVo.setSegmentNo(courseClass.getSegmentNo());
            employeeAttendanceVo.setGradeId(courseClass.getGradeId());
            employeeAttendanceVo.setGradeName(courseClass.getGradeName());
            employeeAttendanceVo.setSubjectId(courseClass.getSubjectId());
            employeeAttendanceVo.setSubjectName(courseClass.getSubjectName());
            employeeAttendanceVo.setPeriodId(courseClass.getPeriodId());
            employeeAttendanceVo.setPeriodName(courseClass.getPeriodName());
            employeeAttendanceVo.setCampusId(courseClass.getCampusId());
            employeeAttendanceVo.setCampusName(courseClass.getCampusName());
            employeeAttendanceVo.setRoomName(courseClass.getRoomName());
            employeeAttendanceVo.setLectureNo(attendClassLecture.getLectureNo());
            employeeAttendanceVo.setClassDate(attendClassLecture.getClassDate());
            employeeAttendanceVo.setClassTime(attendClassLecture.getStartTime()+"-"+attendClassLecture.getEndTime());
            employeeAttendanceVo.setAttendanceStudentNum(attendClassLecture.getAttendanceAmount());
            employeeAttendanceVo.setTotalNum(attendClassLecture.getTotalAmount());
            employeeAttendanceVo.setEmployeeName(teacher.getTeacherName());
            employeeAttendanceVo.setEmployeeId(teacher.getTeacherId());
            employeeAttendanceVo.setUniqueId(teacher.getIdNo());
            employeeAttendanceVoList.add(employeeAttendanceVo);
        }
        return employeeAttendanceVoList;
    }



    @Override
    public List<BusTeamPeriodConsumeVo> findBusTeamPeriodConsumeList(List<Long> periodIds) {
        List<BusTeamPeriodConsumeVo> busTeamPeriodConsumeVoList=new ArrayList<>();

        /*key=periodId*/
        ConcurrentHashMap<Long,List<BusTeamPeriodConsumeVo>> map=new ConcurrentHashMap<>(periodIds.size());


        List<Callable<List<BusTeamPeriodConsumeVo>>> taskList  = new ArrayList<>(periodIds.size());

        for(final Long periodId : periodIds ){

            taskList.add(new Callable<List<BusTeamPeriodConsumeVo>>() {
                @Override
                public List<BusTeamPeriodConsumeVo> call() throws Exception {

                    return consumeRecordService.findBusTeamPeriodConsumeVo(periodId);
                }
            });
        }
        try {
            List<Future<List<BusTeamPeriodConsumeVo>>> futures = Threads.invokeAll(taskList);
            for(Future<List<BusTeamPeriodConsumeVo>> f : futures ){
                List<BusTeamPeriodConsumeVo> busTeamPeriodConsumeVos=f.get();
                if (Utils.checkListNotEmpty(busTeamPeriodConsumeVos)){
                    BusTeamPeriodConsumeVo busTeamPeriodConsumeVo=f.get().get(0);
                    map.put(busTeamPeriodConsumeVo.getPeriodId(),f.get());
                }

            }

        }catch (Exception e){
            throw new BusException("server error");
        }
        for (Long periodId:periodIds){
            List<BusTeamPeriodConsumeVo> list=map.get(periodId);
            if (Utils.checkListNotEmpty(list)){
                busTeamPeriodConsumeVoList.addAll(list);
            }
        }

        return busTeamPeriodConsumeVoList;
    }

    private Map<Long,BusTeam> findBusTeamMapByTeacherList(List<Teacher> teacherList){
        List<Long> busTeamIds=Utils.removeDuplicate(BeanUtils.toList(teacherList,"busTeamId"));
        List<BusTeam> busTeamList=busTeamService.findByIds(busTeamIds);
        return BeanUtils.toMap(busTeamList,"busTeamId");
    }
    private Map<Long,AreaTeam> findAreaTeamMapByTeacherList(List<Teacher> teacherList){
        List<Long> areaTeamIds=Utils.removeDuplicate(BeanUtils.toList(teacherList,"areaTeamId"));
        List<AreaTeam> areaTeamList=areaTeamService.findByIds(areaTeamIds);
        return BeanUtils.toMap(areaTeamList,"areaTeamId");
    }
    private void fillEmployeeBassMessage(EmployeeMessageBaseVo employeeMessageBaseVo, Teacher teacher, AreaTeam areaTeam,BusTeam busTeam){
        employeeMessageBaseVo.setUniqueId(teacher.getIdNo());
        employeeMessageBaseVo.setEmployeeName(teacher.getTeacherName());
        employeeMessageBaseVo.setEmployeeId(teacher.getTeacherId());
        employeeMessageBaseVo.setFunction(EnumUtils.getName(AccessTypeEnum.values() ,teacher.getAccessType()));
        employeeMessageBaseVo.setJobNature(EnumUtils.getName(JobNatureEnum.values(),teacher.getJobNature()));
        if (areaTeam!=null){
            employeeMessageBaseVo.setAreaTeamId(areaTeam.getAreaTeamId());
            employeeMessageBaseVo.setAreaTeamName(areaTeam.getName());
        }
        if (busTeam!=null){
            employeeMessageBaseVo.setBusTeamId(busTeam.getBusTeamId());
            employeeMessageBaseVo.setBusTeamName(busTeam.getName());
        }
    }
}